local ruoyu = fk.CreateSkill {

  name = "joyex__ruoyu$",

  tags = { Skill.Wake, },

}



ruoyu:addEffect(fk.EventPhaseStart, {
  name = "joyex__ruoyu$",
  frequency = Skill.Wake,
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(ruoyu.name) and
      player:usedSkillTimes(ruoyu.name, Player.HistoryGame) == 0 and
      player.phase == Player.Start
  end,
  can_wake = function(self, event, target, player, data)
    return table.every(player.room:getOtherPlayers(player), function(p) return p.hp >= player.hp end)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:changeMaxHp(player, 1)
    if player:isWounded()  then
      room:recover({
        who = player,
        num = 1,
        recoverBy = player,
        skillName = ruoyu.name,
      })
    end
    room:handleAddLoseSkills(player, "joyex__jijiang|ol_ex__sishu", nil, true, false)
  end,
})

return ruoyu